package tk.djcrazy.instantmessage.action;

import java.util.Map;

import javax.annotation.Resource;

import org.apache.struts2.interceptor.SessionAware;

import tk.djcrazy.instantmessage.service.IFriendGroupService;

import com.opensymphony.xwork2.ActionSupport;

public class AddGroupAction extends ActionSupport implements SessionAware{
 	private static final long serialVersionUID = 1883983062270132812L;
 	private String groupName;
 	private Map<String, Object> session;
 	private String result="failed";
 	private String message="";
 	@Resource
 	private IFriendGroupService friendGroupService;
 	
 	public String execute() {
		try {
			friendGroupService.addFriendGroup((Integer) session.get("uid"), groupName);
			result = "success";
			message="分组添加成功";
		} catch (Exception e) {
			e.printStackTrace();
			result = "failed";
			message="分组添加失败:(";
		}
		return SUCCESS;
	}
 	
	public String getGroupName() {
		return groupName;
	}
	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public IFriendGroupService getFriendGroupService() {
		return friendGroupService;
	}

	public void setFriendGroupService(IFriendGroupService friendGroupService) {
		this.friendGroupService = friendGroupService;
	}

	public Map<String, Object> getSession() {
		return session;
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
 	
}
